package org.gao.test.transaction.Standalone;

import java.sql.Connection;
import java.sql.SQLException;

public class TransactionManager {

	private Connection conn;
	
	public TransactionManager(Connection conn) {
		this.conn = conn;
	}
	
	public void beginTransaction() {
		try {
			conn.setAutoCommit(false);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public void commit() {
		try {
			conn.commit();
			//conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public void rollback() {
		try {
			conn.rollback();
			conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
